var unalteredCombatUI = window.showEndOfCombatUI;
var lastHostingPlayer;

window.showEndOfCombatUI = function(a){
	//show the end of combat UI as long as setting to hide it is disabled
	(!hideCombatWinScreen) && unalteredCombatUI(a);
	var playerObj = UserCharacter.currentUserCharacter();
	var playerId = playerObj.getId();
	//covers both versions of lucky horseshoe
	var lucky = playerObj.getBuffExpirationTime("buff-double-rare");
	var lootItem = Market.getItem(a.loot);
	lootItem = lootItem.name;
	lootItem = lootItem.replace(/\sx\d{1,4}/g, "");
	//tag with number of objects won
	if(a.lootCount > 1)
		lootItem = lootItem + " x" + a.lootCount;
	
    //testing participants
    //hideCombatWinScreen && $("#statusMessage").text("Coins: "+a.coins+", XP: "+a.xp+" \nLoot: "+lootItem+" \nPlayers:"+playersToNames(lastHuntingPlayers)).fadeIn(500).delay(10000).fadeOut(500);
    
    //testing host and level
    //$("#statusMessage").text("Coins: "+a.coins+", XP: "+a.xp+" \nLoot: "+lootItem+" \nHosted By: "+Player.playerWithId(lastHostingPlayer).getHandle()+" \nZP: Level "+zpLevel);
	
	//just the loot
	hideCombatWinScreen && $("#statusMessage").text("XP: "+a.xp+" \nLoot: "+lootItem).fadeIn(500).delay(10000).fadeOut(500);
	$.post("http://www.jsommers.com/logloot.php", 
		{"level":a.level, "coins":a.coins, "survivors":a.survivors, 
		"loot":lootItem, "xp":a.xp, "player":playerId, "lootCount":a.lootCount,
		"rare":a.rare, "maxLuck":a.maxSkill});
}

PreCombatUI.prototype.updateCurrentPlayersInCombat = (function() {
	PreCombatUI.prototype.unalteredUpdatePlayers = PreCombatUI.prototype.updateCurrentPlayersInCombat;
	return function(a){
		//extending PreCombatUI.updateCurrentPlayersInCombat(message), extension goes first because updatePlayers clears the player list
		if(a && a.removeCombatUI){
			// Intentionally left blank out of laziness then wrote a long comment to completely invalidate that statement
		}
		else{
			//message is a player update, log the combat initiator to be referenced as hosting player later
			lastHostingPlayer = a.initiator;
		}
		this.unalteredUpdatePlayers(a);
	}
})();